package com.winchain.chainbill.bill.biz.discount.rx;

import com.shell.framework.command.ChainBase;
import com.shell.framework.command.CommandContext;
import com.shell.framework.rx.OnErrorNotImplementedSubscriber;
import com.winchain.chainbill.bill.base.po.CbDct;
import com.winchain.chainbill.bill.biz.Bill;
import com.winchain.chainbill.bill.biz.send.cmd.BillMoveCmd;
import com.winchain.chainbill.bill.biz.send.cmd.BillOptCmd;
import com.winchain.chainbill.bill.biz.transfer.vo.BillSplitEvent;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

@Component
public class BillDctPrntSubscriber extends OnErrorNotImplementedSubscriber<BillSplitEvent<CbDct>> {
	@Autowired
	private BillMoveCmd<CbDct> billMoveCmd;
	@Autowired
	private BillOptCmd<CbDct> billOptCmd;

	public void onApplicationEvent(BillSplitEvent<CbDct> t) {
		CommandContext<Bill<CbDct>> context = new CommandContext();

		context.setSource(t.getBill());
		context.setValue("Operation", t.getOperation());

		ChainBase<Bill<CbDct>> crb = new ChainBase();
		crb.add(this.billOptCmd);
		crb.add(this.billMoveCmd);
		crb.execute(context);
	}
}
